#include <iostream>
#include <string.h>
#include <set>
using namespace std;

set<int> s;


int dfs(int n,int m,int weight,int *a,bool *vis){
	if(m == 0){
		if(s.count(weight) == 0){
			s.insert(weight);
			return 1;
		}
		else{
			return 0;
		}
	}
	int sum=0;
	for(int i=0;i<n;i++){
		if(vis[i] == false){
			vis[i] = true;
			sum += dfs(n,m-1,weight+a[i],a,vis);
			vis[i] = false;
		}
	}
	return sum;
}



int main(){
	int n,m;
	cin>>n>>m;
	m = n-m;
	int a[n];
	bool vis[n];
	memset(vis,false,sizeof(vis));
	for(int i=0;i<n;i++)
		cin>>a[i];
	cout<<dfs(n,m,0,a,vis);
	return 0;
}
